Notices.tsx 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. "use client";
  2. import { GlobalNoticeRep } from "@/api/home";
  3. import Box from "@/components/Box";
  4. import Empty from "@/components/Empty";
  5. import { timeFormat } from "@/utils/methods";
  6. import { Badge, Collapse } from "antd-mobile";
  7. import { useLocale } from "next-intl";
  8. import style from "./style.module.scss";
  9. interface Props {
  10. data: GlobalNoticeRep[];
  11. type: "system" | "user";
  12. handler: (active: string, key: Props["type"]) => void;
  13. }
  14. const SystemMessage = (props: Props) => {
  15. const { data, type, handler } = props;
  16. const locale = useLocale();
  17. const collapseChange = async (active: string | null) => {
  18. if (!active) return;
  19. handler && handler(active, type);
  20. };
  21. if (!data.length) return <Empty />;
  22. return (
  23. <div className={style.messageCollapse}>
  24. <Collapse accordion onChange={collapseChange}>
  25. {data.map((notice, index) => (
  26. <Collapse.Panel
  27. key={`${notice.id}`}
  28. arrowIcon={
  29. <div className={"flex items-center"}>
  30. {/* <Badge
  31. className={`mr-[0.1rem] h-[0.06rem] w-[0.06rem]`}
  32. style={{ "--color": "#ff311b" }}
  33. content={!notice.is_read ? Badge.dot : ""}
  34. ></Badge> */}
  35. {
  36. !notice.is_read && <div className={`mr-[0.1rem] h-[0.08rem] w-[0.08rem]`} style={{borderRadius: "0.04rem", backgroundColor: "#ff311b"}}></div>
  37. }
  38. <span className={"iconfont icon-zhankai"} />
  39. </div>
  40. }
  41. title={
  42. <section>
  43. <header className={"flex items-center"}>
  44. <h6 className={""}>{notice.content?.title}</h6>
  45. </header>
  46. <p className={"text-[12px] text-[#64676d]"}>
  47. {notice.send_time
  48. ? timeFormat(notice.send_time!, locale)
  49. : timeFormat(notice.send_user_time!, locale)}
  50. </p>
  51. </section>
  52. }
  53. >
  54. <div>
  55. <p className={"text-[16px] text-[#c1c6d2]"}>{notice.content?.text}</p>
  56. <img src={notice.content?.image} alt="" />
  57. <div
  58. className={`-mb-[12px] mt-[0.0694rem] flex h-[0.2778rem] items-center justify-center border-t-[0.006rem] border-[#454545] text-[#64676d]`}
  59. >
  60. <Box
  61. action={notice.action_type}
  62. actionData={notice.action_params}
  63. className={"flex items-center"}
  64. >
  65. <p className={"text-[0.1111rem]"}>{notice.content?.word} </p>
  66. <span
  67. className={
  68. "iconfont icon-xiangyou2 ml-[5px] text-[0.08rem]"
  69. }
  70. ></span>
  71. </Box>
  72. </div>
  73. </div>
  74. </Collapse.Panel>
  75. ))}
  76. </Collapse>
  77. </div>
  78. );
  79. };
  80. export default SystemMessage;